<?php 
	$total_reg = "6";
	if(isset($_GET['pg'])){
		$pg  = $_GET['pg'];
	}else{
		$pg = "1";
	}
	$inicio = $pg - 1;
	$inicio = $inicio * $total_reg;

	$sql_notice_total = mysql_query("SELECT id,titulo,foto_principal,descricao_foto,texto,fonte FROM tbl_noticias  ORDER BY id DESC ");	
	$tr = mysql_num_rows($sql_notice_total);
	$sql_notice = mysql_query("SELECT id,titulo,foto_principal,descricao_foto,texto,fonte FROM tbl_noticias  ORDER BY id DESC LIMIT ".$inicio.",".$total_reg." ");
	$resultado = mysql_num_rows($sql_notice);

	$tp = ceil($tr / $total_reg); // verifica o número total de páginas

?>
<div class="content2" style="margin-top:15px;">
    <div style="background-color:#999;width:660px;height:45px;">
    <div style="width:100px;height:30px;position:relative;left:20px;top:10px;font-family:'Trebuchet MS', Arial, Helvetica, sans-serif;font-size:20px;color:white;">
    Not&iacute;cias</div>
    </div>
	<style type="text/css">
    .aNotice {
    text-decoration:none;
	font-size:14px;
	font-family:Tahoma, Geneva, sans-serif;
    /*color:#49b4d6;*/
	color:#232323;
    }
    .aNotice:hover{
    color:#999;/*#093;*/
    }
    .aNotice:visited{
    color:#444;
    }
	#botoes{
		width:600px;
		height:50px;
		position:relative;
		/*border-top:1px solid #000;*/
		left:20px;
	}
	#div_a{
		width:34px;
		height:32px;
		position:relative;
		float:left;
		top:10px;
	}
	#div_p{
		width:34px;
		height:32px;
		left:535px;
		float:left;
		position:relative;	
		top:10px;
	}
    </style>
	<?php
    if($resultado > 0){
        while(list($codigo,$tituloN,$foto_principal,$descricao_foto,$texto,$fonte)=mysql_fetch_array($sql_notice)){
    ?>
    <div style="margin-left:10px;margin-top:10px;border-bottom:1px solid #F93;float:left;">
        <div style="position:relative;box-shadow:4px 4px 4px #666;width:80px;height:50px;float:left;">
        <a href="noticias_page&noticia=<?php echo base64_encode($codigo); ?>">
        <img src="noticias/thumb/<?php echo $foto_principal;?>" /></a>
        </div>
        <div style="width:560px;float:left;position:relative;top:-15px;left:10px;">
        <p><a class="aNotice" href="noticias_page&noticia=<?php echo base64_encode($codigo); ?>">
		<b><?php echo $tituloN; ?></b>
        </a><br />
        <font style="font-family:Tahoma, Geneva, sans-serif;font-size:12px;">
        <?php echo $descricao_foto."....."; ?></font>&nbsp;
        <a class="aNotice" style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif;font-size:11px;" href="noticias_page&noticia=<?php echo base64_encode($codigo); ?>">Leia mais</a>
        </p>
        </div>
    </div>
    <div style="clear:both;"></div>
    <?php 
        }
    }
	?>
    <div style="clear:both;"></div>
    <script>
    function hproximo(){document.getElementById('pro').src = "img/imagens/proximo2.png";}
	function outproximo(){document.getElementById('pro').src ="img/imagens/proximo1.png";}
	function hanterior(){document.getElementById('ant').src ="img/imagens/anterior2.png";}
	function outanterior(){document.getElementById('ant').src ="img/imagens/anterior1.png";}
    </script>
	<div id="botoes">
	<?php
		$anterior = $pg -1;
		$proximo = $pg +1;
		if ($pg > 1) {?>
        <div id="div_a">
		<?php
		echo " <a href='index.php?pagina=internas/noticias.php&pg=$anterior'><img onmouseout=\"outanterior();\" onmouseover=\"hanterior();\"  src=\"img/imagens/anterior1.png\" id=\"ant\"/></a> ";
		?>
        </div>
		<?php }
		?>
        
        <?php
		if ($pg < $tp) {?>
        <div id="div_p">
        <?php
		echo " <a href='index.php?pagina=internas/noticias.php&pg=$proximo'><img onmouseout=\"outproximo();\" onmouseover=\"hproximo();\" src=\"img/imagens/proximo1.png\" id=\"pro\" /></a>";
		?>
        </div>
		<?php }?>
    </div>   
</div>   
